package com.csii.activiti.server.core.service;

import java.util.HashMap;
import java.util.Map;

public interface FlowEngineService {

    Map<String, Object> queryRuVariables(String processInstanceId);

    default Map<String, Object> queryRuVariablesPrefixVariableName(String processInstanceId,String prefixVariableName){
        Map<String, Object> variables = queryRuVariables(processInstanceId);
        Map<String, Object> resultMap= new HashMap<>();
        for (Map.Entry<String, Object> item : variables.entrySet()) {
            if (item.getKey().startsWith(prefixVariableName)){
                resultMap.put(item.getKey(),item.getValue());
            }
        }
        return resultMap;
    }

    Map<String, Object> queryHiVariables(String processInstanceId);

    default Map<String, Object> queryHiVariablesPrefixVariableName(String processInstanceId,String prefixVariableName){
        Map<String, Object> variables = queryHiVariables(processInstanceId);
        Map<String, Object> resultMap= new HashMap<>();
        for (Map.Entry<String, Object> item : variables.entrySet()) {
            if (item.getKey().startsWith(prefixVariableName)){
                resultMap.put(item.getKey(),item.getValue());
            }
        }
        return resultMap;
    }
}
